package 第三章作业;

import java.io.File;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;

public class Work5 {
   static List fileJias=new ArrayList();
    static List fileNames=new ArrayList();
    public  static void  getfile(File file) throws Exception {
      File[] files=file.listFiles();
      for (int i = 0; i <files.length ; i++) {
            if (!(files[i]==null)&&files[i].isDirectory()){
                fileJias.add(files[i].getName());
                getfile(files[i]);
            }
            if (!(files[i]==null)&&files[i].isFile()){
                fileNames.add(files[i].getName());
            }
        }

    }

    public static void main(String[] args) throws Exception{
       Work5.getfile(new File("C:\\Program Files (x86)\\360\\360safe"));
        System.out.println("文件夹：");
        System.out.println();
        for (Object obj:fileJias) {
            System.out.println(obj);
        }
        System.out.println();
        System.out.println();
        System.out.println("文件：");
        for(Object obj:fileNames){
            System.out.println(obj);
        }
    }
}
